package com.kaibes.platform.file.server;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kaibes.core.base.util.StringUtils;
import com.kaibes.web.api.ApiLink;
import com.kaibes.web.api.ResponseApi;
import com.kaibes.web.response.ResponseFactory;

@RestController
@RequestMapping("/files/clients")
public class FileClientApi extends ResponseApi<FileClient, FileClientService> {

    @PutMapping
    @ApiLink("随机生成通信密钥")
    public ResponseEntity<Object> put(@RequestAttribute Integer userId) {
        FileClientU fileClient = new FileClientU();
        fileClient.setAesKey(StringUtils.random(16));
        fileClient.setAesIv(StringUtils.random(16));
        return ResponseFactory.put(service.updateByUserId(fileClient, userId), "生成AES密钥成功", "生成AES密钥失败");
    }
    
    
}
